module.exports.directoryExists   A
last analyzed

Complexity

Conditions 2
Paths 4

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 2
c 1
b 0
f 1
nc 4
dl 0
loc 8
rs 9.4285
nop 1
1
const fs = require('fs');
2
const path = require('path');
3
4
module.exports = {
5
  getCurrentDirectoryBase() {
6
    return path.basename(process.cwd());
7
  },
8
9
  getCurrentWorkingDir() {
10
    return process.cwd();
11
  },
12
13
  /**
14
   * check if a file or directory exists
15
   * @param {String} filePath - file path to check
16
   * @returns {Boolean} if exists return true else return false
17
   */
18
  directoryExists(filePath) {
19
    try {
20
      return fs.statSync(filePath).isDirectory()
21
        || fs.statSync(filePath).isFile();
22
    } catch (err) {
23
      return false;
24
    }
25
  }
26
};
27